home *** CD-ROM | disk | FTP | other *** search
- #include "Win95Look.h"
-
- // ---------------------------------------------------------------------------
-
- void W95DrawChar(
- char theChar,
- const RGBColor *textColor,
- const RGBColor *embossColor) {
-
- W95DrawText((Ptr)&theChar, 1, textColor, embossColor);
- } // END W95DrawChar
-
- // ---------------------------------------------------------------------------
-
- void W95DrawText(
- char *text,
- unsigned short length,
- const RGBColor *textColor,
- const RGBColor *embossColor) {
-
- RGBColor saveFore;
- short saveTxMode;
- GrafPtr savePort;
- short curHLoc, curVLoc;
-
- // Get current port settings
- GetPort(&savePort);
- saveTxMode = savePort->txMode;
- GetForeColor(&saveFore);
- curHLoc = savePort->pnLoc.h;
- curVLoc = savePort->pnLoc.v;
- TextMode(srcOr);
-
- Move(1, 1);
- RGBForeColor(embossColor);
- // Draw emboss text
- DrawText(text, 0, length);
-
- MoveTo(curHLoc, curVLoc);
- RGBForeColor(textColor);
- // Draw text
- DrawText(text, 0, length);
-
- // Restore port settings
- TextMode(saveTxMode);
- RGBForeColor(&saveFore);
- } // END W95DrawText
-
- // ---------------------------------------------------------------------------
-
- void W95DrawTextAt(
- char *text,
- unsigned short length,
- short h,
- short v,
- const RGBColor *textColor,
- const RGBColor *embossColor) {
-
- MoveTo(h, v);
- W95DrawText(text, length, textColor, embossColor);
- } // END W95DrawTextAt
-
- // ---------------------------------------------------------------------------
-
- /*
- We special case for horizontal and vertical lines.
- For horizontal lines, the hilite line is one pixel below the line.
- For vertical lines, the hilite line is drawn one pixel to the right.
- Other lines, the hilite line is drawn down and right one pixel.
- */
- void W95LineTo(
- short h,
- short v,
- const RGBColor *lineColor,
- const RGBColor *hiliteColor) {
-
- GrafPtr savePort;
- RGBColor saveFore;
- short curHLoc, curVLoc;
-
- GetPort(&savePort);
- GetForeColor(&saveFore);
- curHLoc = savePort->pnLoc.h;
- curVLoc = savePort->pnLoc.v;
-
- // Draw hilite line
- RGBForeColor(hiliteColor);
- if (curHLoc == h) {
- // Vertical line
- Move(1, 0);
- LineTo(h+1, v);
- }
- else if (curVLoc == v) {
- // Horizontal line
- Move(0, 1);
- LineTo(h, v+1);
- }
- else {
- Move(1, 1);
- LineTo(h+1, v+1);
- }
-
- // Draw shadow line
- RGBForeColor(lineColor);
- MoveTo(curHLoc, curVLoc);
- LineTo(h, v);
-
- // Restore fore color
- RGBForeColor(&saveFore);
- } // END W95LineTo
-
- // ---------------------------------------------------------------------------
-
- void W95DrawRect(
- const Rect *frame,
- const RGBColor *lineColor,
- const RGBColor *hiliteColor) {
-
- // Since the line-drawing saves and restore the colors, there's no
- // need for us to do it. However, we have to make sure we draw
- // only inside the frame...
-
- // Draw left
- MoveTo(frame->left, frame->top);
- W95LineTo(frame->left, frame->bottom, lineColor, hiliteColor);
-
- // Draw top
- MoveTo(frame->left, frame->top);
- W95LineTo(frame->left+1, frame->top, lineColor, hiliteColor);
-
- // Draw right
- MoveTo(frame->right-2, frame->top);
- W95LineTo(frame->right-2, frame->bottom, lineColor, hiliteColor);
-
- // Draw bottom
- MoveTo(frame->left, frame->bottom-2);
- W95LineTo(frame->right-1, frame->bottom-2, lineColor, hiliteColor);
- } // END W95DrawRect
-
- // ---------------------------------------------------------------------------
-
- /*
- Draw a rightward-pointing arrow.
- */
-
- void W95DrawTriangleRight(
- const Rect *triangleBounds,
- Boolean exactWin95Look,
- const RGBColor *lineColor,
- const RGBColor *hiliteColor,
- const RGBColor *fillColor) {
-
- short halfHeightLoc;
- RGBColor saveFore;
-
- GetForeColor(&saveFore);
-
- halfHeightLoc = triangleBounds->top +
- ((triangleBounds->bottom - triangleBounds->top) / 2);
-
- if (!exactWin95Look) {
- RGBForeColor(lineColor);
- MoveTo(triangleBounds->left, triangleBounds->top);
- LineTo(triangleBounds->right, halfHeightLoc);
- MoveTo(triangleBounds->left, triangleBounds->top);
- LineTo(triangleBounds->left, triangleBounds->bottom);
- RGBForeColor(hiliteColor);
- //MoveTo(triangleBounds->left, triangleBounds->bottom);
- LineTo(triangleBounds->right, halfHeightLoc);
- }
- else {
- RgnHandle triangle;
-
- triangle = NewRgn();
- OpenRgn();
-
- MoveTo(triangleBounds->left, triangleBounds->top);
- LineTo(triangleBounds->right, halfHeightLoc);
- MoveTo(triangleBounds->left, triangleBounds->top);
- LineTo(triangleBounds->left, triangleBounds->bottom);
- //MoveTo(triangleBounds->left, triangleBounds->bottom);
- LineTo(triangleBounds->right, halfHeightLoc);
-
- CloseRgn(triangle);
- RGBForeColor(fillColor);
- PaintRgn(triangle);
- DisposeRgn(triangle);
- }
-
- RGBForeColor(&saveFore);
- } // END W95DrawTriangleRight
-
- // ---------------------------------------------------------------------------
-
- /*
- Draw a downward-pointing arrow.
- */
- void W95DrawTriangleDown(
- const Rect *triangleBounds,
- Boolean exactWin95Look,
- const RGBColor *lineColor,
- const RGBColor *hiliteColor,
- const RGBColor *fillColor) {
-
- short halfWidthLoc;
- RGBColor saveFore;
-
- GetForeColor(&saveFore);
-
- halfWidthLoc = triangleBounds->left +
- ((triangleBounds->right - triangleBounds->left) / 2);
-
- if (!exactWin95Look) {
- RGBForeColor(lineColor);
- MoveTo(triangleBounds->left, triangleBounds->top);
- LineTo(triangleBounds->right, triangleBounds->top);
- MoveTo(triangleBounds->left, triangleBounds->top);
- LineTo(halfWidthLoc, triangleBounds->bottom);
- RGBForeColor(hiliteColor);
- LineTo(triangleBounds->right, triangleBounds->top);
- //LineTo(halfWidthLoc, triangleBounds->bottom);
- }
- else {
- RgnHandle triangle;
-
- triangle = NewRgn();
- OpenRgn();
-
- MoveTo(triangleBounds->left, triangleBounds->top);
- LineTo(triangleBounds->right, triangleBounds->top);
- MoveTo(triangleBounds->left, triangleBounds->top);
- LineTo(halfWidthLoc, triangleBounds->bottom);
- LineTo(triangleBounds->right, triangleBounds->top);
- //LineTo(halfWidthLoc, triangleBounds->bottom);
-
- CloseRgn(triangle);
- RGBForeColor(fillColor);
- PaintRgn(triangle);
- DisposeRgn(triangle);
- }
-
- RGBForeColor(&saveFore);
- } // END W95DrawTriangleDown
-
- // ---------------------------------------------------------------------------
-
- void W95DrawEmbossedButton(
- const Rect *btnRect,
- Boolean pushedIn,
- const RGBColor *baseColor,
- const RGBColor *hiliteColor,
- const RGBColor *shadowColor,
- const RGBColor *frameColor) {
-
- RGBColor saveFore;
- RGBColor frameRGB;
-
- GetForeColor(&saveFore);
-
- RGBForeColor(shadowColor);
- // Outer top shadow line
- MoveTo(btnRect->left, btnRect->top);
- LineTo(btnRect->right, btnRect->top);
- // Outer left shadow line
- MoveTo(btnRect->left, btnRect->top);
- LineTo(btnRect->left, btnRect->bottom);
-
- // Inner right shadow line
- MoveTo(btnRect->right-1, btnRect->top+3);
- LineTo(btnRect->right-1, btnRect->bottom-1);
- // Inner bottom shadow line
- MoveTo(btnRect->left+3, btnRect->bottom-1);
- LineTo(btnRect->right-1, btnRect->bottom-1);
-
- RGBForeColor(hiliteColor);
- // Inner top hilite line
- MoveTo(btnRect->left+2, btnRect->top+2);
- LineTo(btnRect->right-1, btnRect->top+2);
- // Inner left hilite line
- MoveTo(btnRect->left+2, btnRect->top+2);
- LineTo(btnRect->left+2, btnRect->bottom-1);
-
- if (frameColor == NULL) {
- // Default: black frame
- frameRGB.red = frameRGB.green = frameRGB.blue = 0x0000;
- }
- else
- frameRGB = *frameColor;
-
- RGBForeColor(&frameRGB);
- // Left frame
- MoveTo(btnRect->left+1, btnRect->bottom);
- LineTo(btnRect->left+1, btnRect->top+1);
- // Top frame
- LineTo(btnRect->right, btnRect->top+1);
- // Right frame
- LineTo(btnRect->right, btnRect->bottom);
- // Bottom frame
- LineTo(btnRect->left+1, btnRect->bottom);
-
- // Restore fore color
- RGBForeColor(&saveFore);
- } // END W95DrawEmbossedButton